import React, { Component, PureComponent } from 'react'

export default class Test extends PureComponent {
  state = {
    msg: 'hello',
    obj: {
      name: 'zs',
    },
  }

  render() {
    const { msg, obj } = this.state
    console.log('Test的render执行了')
    return (
      <>
        <div>
          Test, {msg},{obj.name}
        </div>
        <button
          onClick={() => {
            this.setState({
              msg: '123',
            })
          }}
        >
          test的按钮
        </button>
        <button
          onClick={() => {
            const newObj = { ...obj }
            newObj.name = 'ls'
            this.setState({
              obj: newObj,
            })
          }}
        >
          test的按钮-点击修改obj
        </button>
      </>
    )
  }
}
